package com.smh.a04PokerGameDemo1;

import java.util.ArrayList;
import java.util.Collections;

public class PokerGame {
    static ArrayList<String> pokerCord = new ArrayList<>();

    //生成牌组
    //静态代码块
    //类加载的时候加载,且只加载一次
    static {
        ArrayList<String> color = new ArrayList<>();
        Collections.addAll(color,"♥","♠","♦","♣");
        ArrayList<String> number = new ArrayList<>();
        Collections.addAll(number,"1","2","3","4","5","6","7","8","9","10","J","Q","K");

        for (String c : color) {
            for (String n : number) {
                pokerCord.add(c+n);
            }
        }
        pokerCord.add("小王");
        pokerCord.add("大王");
        System.out.println(pokerCord);
    }


    public PokerGame() {
        //打乱
        Collections.shuffle(pokerCord);
        //发牌
        //地主()
        ArrayList<String> lord = new ArrayList<>();
        ArrayList<String> player1 = new ArrayList<>();
        ArrayList<String> player2 = new ArrayList<>();
        ArrayList<String> player3 = new ArrayList<>();

        for (int i = 0; i < pokerCord.size(); i++) {
            if (i<3){
                lord.add(pokerCord.get(i));
                continue;
            }

            if (i%3==0){
                player1.add(pokerCord.get(i));
            } else if (i%3==1) {
                player2.add(pokerCord.get(i));
            }else {
                player3.add(pokerCord.get(i));
            }
        }

        //看牌
        System.out.println(player1);
        System.out.println(player2);
        System.out.println(player3);

    }
}
